package test.netty.server;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author cuichao
 * @Description: ClientChannel
 * @Date: create in 2020/12/21 15:02
 */
@ChannelHandler.Sharable
public class ServerChannel extends SimpleChannelInboundHandler<String> {


    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("ServerChannel active");
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
        System.out.println("客户端消息: "+msg);
       /* ctx.writeAndFlush("world");*/
    }


    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        System.out.println("ServerChannel异常处理:"+cause);
        cause.printStackTrace();

    }
}
